<template>
	<div class="container">
		<div class="form-signin">
			<h2 class="form-signin-heading" @click="gotoHome">
				Please sign in
			</h2>
			<label for="inputEmail" class="sr-only">Email address</label>
			<input
				type="text"
				class="form-control"
				placeholder="Email address"
				required
				autofocus
				v-model="userName"
			/>
			<label for="inputPassword" class="sr-only">Password</label>
			<input
				type="password"
				id="inputPassword"
				class="form-control"
				placeholder="Password"
				v-model="passWord"
				required
			/>
			<div class="checkbox">
				<label>
					<input type="checkbox" value="remember-me" /> Remember me
				</label>
			</div>
			<button class="btn btn-lg btn-primary btn-block" @click="login()">
				Sign in
			</button>
		</div>
	</div>
</template>

<script>
import { userLogin } from '@/api';

export default {
	data() {
		return {
			userName: 'test',
			passWord: '123123',
		};
	},
	methods: {
		gotoHome() {
			this.$router.push('/');
		},
		async login() {
			console.log('1111');
			let res = await userLogin({
				userName: this.userName,
				passWord: this.passWord,
			});
			console.log(res);
			if (res.status == 200) {
				localStorage.setItem('Token', res.data.Data.Token);
				this.$router.push('/');
			}
		},
	},
};
</script>

<style lang="scss" scoped></style>
